using System;
using SCG.General;

namespace SCG.SolarVengeanceEngine
{
    public class StarShipDescriptor
    {
        //constructors
        public StarShipDescriptor(StarShipType type, int engines, int value, bool cloaked)
        {
            ShipType = type;
            Engines = engines;
            Value = value;
            Cloaked = cloaked;
        }
        public StarShipDescriptor(string s)
        {
            SVTokenizer tok = new SVTokenizer(null, s);
            ShipType = tok.TokenStarShipType;
            Engines = tok.TokenInt;
            Value = tok.TokenInt;
            Cloaked = tok.TokenBoolean;
        }

        //StarShip type
        public StarShipType ShipType { get; set; }
     
        //Engines
        public int Engines { get; set; }

        //Value
        public int Value { get; set; }

        //Cloaked?
        public bool Cloaked { get; set; }

        //persistence
        public string Persist()
        {
            SVTokenizer tok = new SVTokenizer(null);
            return tok.Tokenize(ShipType, Engines, Value, Cloaked);
        }

        //Descriptive string
        public string Description
        {
            get
            {          
                string s = ShipType.ToString() + " E" + Engines;            
                if (ShipType.GetPrimarySystemName() != "")
                    s += " " + ShipType.GetPrimarySystemAbbreviation() + Value;
                if (Cloaked)
                    s += " (clk)";
                return s;
            }
        }  
    }
}
